<template>
    <div class="header">
        <div class="titleHeader"> 套餐专享</div>
        <ul>
            <li v-for="item, index in discountList" :key="item.packageId">
                <div class="liLeft">
                    <img :src="item.Packageimg" alt="">
                </div>

                <div class="liCenter">
                    <span class="sp1">{{ item.PackageName }}</span><br>
                    <span class="sp2">{{ item.PackageIntroduce }}</span>
                </div>
                <div class="liRight">
                    <button @click="changePackage(item.packageId)">抢购</button><br>
                    <span class="sp3">半年时量{{ item.salesVolume }}</span>
                </div>

            </li>

        </ul>
        <div class="more"><a href="#">更多优惠套餐</a></div>
    </div>
</template>

<script setup>
import { getDiscount } from '@/api/api'
import router from '@/router/index'
import { ref, onMounted } from 'vue'
import useZBStore from '@/pinia/index'
const useStore = useZBStore()
const changePackage = (packageId) => {
    localStorage.setItem('packageId', packageId)
    router.push({ name: `package${packageId}`, query: { packageId } })
}

const discountList = ref([])
onMounted(async () => {
    // 获取id
    let uid = localStorage.getItem('uId')
    let { data } = await getDiscount({ id: uid })
    discountList.value = data
})
</script>

<style lang="scss" scoped>
.header {
    .titleHeader {
        color: rgba(56, 56, 56, 1);
        font-size: 28px;
        box-sizing: border-box;
        line-height: 45px;
        border-bottom: 1px solid #ccc;
        padding: 38px 0 0 32px;
        font-weight: bold;
    }

    ul {
        font-size: 16px;
        display: flex;
        flex-direction: column;

        li {
            width: 100%;
            height: 190px;
            display: flex;
            justify-content: space-between;
            border-bottom: 1px solid #ccc;
            padding: 21px 0 0 32px;
            box-sizing: border-box;

            .liLeft {
                img {
                    width: 100px;
                    height: 100px;
                    margin: 15px 30px 42px 0px;


                }
            }

            .liCenter {
                .sp1 {
                    width: 156px;
                    height: 42px;
                    display: inline-block;
                    color: rgba(56, 56, 56, 1);
                    font-size: 28px;
                    line-height: 150%;
                    text-align: left;
                }

                .sp2 {
                    display: inline-block;
                    width: 352px;
                    height: 66px;
                    color: rgba(166, 166, 166, 1);
                    font-size: 22px;
                    line-height: 150%;
                    text-align: left;
                }
            }

            .liRight {
                width: 25%;

                button {
                    width: 100px;
                    height: 48px;
                    margin: 23px 0 10px 40px;
                    color: rgba(255, 255, 255, 1);
                    background-color: rgba(255, 141, 26, 1);
                    border-radius: 16px;
                    font-size: 28px;
                    line-height: 150%;
                    border: 0;
                }

                .sp3 {
                    text-align: left;
                    color: rgba(166, 166, 166, 1);
                    font-size: 22px;
                    line-height: 150%;
                }

            }
        }

    }

    .more {
        display: flex;
        justify-content: center;
        align-items: center;
        margin-top: 25px;
        margin-bottom: 56px;

        a {

            color: rgba(255, 141, 26, 1);
            font-size: 28px;
        }

    }

}
</style>